package com.ruoyi.Evaluation.service.impl;

import java.util.List;

import com.ruoyi.DegreePoints.mapper.DegreePointsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.Evaluation.mapper.EvaluationMapper;
import com.ruoyi.Evaluation.domain.Evaluation;
import com.ruoyi.Evaluation.service.IEvaluationService;

/**
 * 评分信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-26
 */
@Service
public class EvaluationServiceImpl implements IEvaluationService 
{
    @Autowired
    private EvaluationMapper evaluationMapper;

    @Autowired
    private DegreePointsMapper degreePointsMapper;

    /**
     * 查询评分信息
     * 
     * @param resultId 评分信息主键
     * @return 评分信息
     */
    @Override
    public Evaluation selectEvaluationByResultId(Long resultId)
    {
        return evaluationMapper.selectEvaluationByResultId(resultId);
    }

    /**
     * 查询评分信息列表
     * 
     * @param evaluation 评分信息
     * @return 评分信息
     */
    @Override
    public List<Evaluation> selectEvaluationList(Evaluation evaluation)
    {
        List<Evaluation> evaluations = evaluationMapper.selectEvaluationList(evaluation);
        System.out.println(evaluations);
        evaluations.forEach(evaluation1 -> {
            evaluation1.setPointName(degreePointsMapper.selectDegreePointsByPointId(evaluation1.getPointId()).getPointName());
        });
        return evaluations;
    }

    /**
     * 新增评分信息
     * 
     * @param evaluation 评分信息
     * @return 结果
     */
    @Override
    public int insertEvaluation(Evaluation evaluation)
    {
        return evaluationMapper.insertEvaluation(evaluation);
    }

    /**
     * 修改评分信息
     * 
     * @param evaluation 评分信息
     * @return 结果
     */
    @Override
    public int updateEvaluation(Evaluation evaluation)
    {
        return evaluationMapper.updateEvaluation(evaluation);
    }

    /**
     * 批量删除评分信息
     * 
     * @param resultIds 需要删除的评分信息主键
     * @return 结果
     */
    @Override
    public int deleteEvaluationByResultIds(Long[] resultIds)
    {
        return evaluationMapper.deleteEvaluationByResultIds(resultIds);
    }

    /**
     * 删除评分信息信息
     * 
     * @param resultId 评分信息主键
     * @return 结果
     */
    @Override
    public int deleteEvaluationByResultId(Long resultId)
    {
        return evaluationMapper.deleteEvaluationByResultId(resultId);
    }
}
